<?php

//require_once APPLICATION_PATH. '/forms/Register.php';

class RegisterController extends Zend_Controller_Action
{
    public function init()
    {
        /* Initialize action controller here */         
        //$this->_helper->viewRenderer->setNoRender();        //ko dung View
        $this->_helper->layout->disableLayout();            //ko load Layout vào ứng dụng 
    }

    public function indexAction()
    {   
        $form = new Application_Form_Register();        
        $this->view->form = $form;
        
        
    }
    
	public function saveAction() {
	
		$form = new Application_Form_Register();

		//		handle if form is invalid
		if (!$form->isValid($_POST)) {
			$this->view->form = $form;
			$this->render('Register');
			return;
		}
		
		//	get form values
		$v = $form->getValues();
		
		//include model
		require_once 'models/User.php';
		$user = new User();
		
		$data = array(
		'username' => $v['username'],
		'email' => $v['email'],		
		'password' => $v['password'],
		'fullname' => $v['fullname'],
		'status' => $v['status']);
		
		$user->insert($data);
		$this->render();		
	}
}



